class Solution {
public:
    void dfs(vector<int>& nums, int index)
    {
        if (index == nums.size())
            return;

        for (int i = index; i < nums.size(); ++i)
        {
            path.push_back(nums[i]);
            ret += getXOR();

            dfs(nums, i + 1);
            path.pop_back();
        }
    }

    int getXOR()
    {
        int XOR = 0;
        for (auto& i : path)
            XOR ^= i;

        return XOR;
    }

    int subsetXORSum(vector<int>& nums) {
        dfs(nums, 0);

        return ret;
    }

private:
    int ret = 0;
    vector<int> path;
};